from django.db import models


# Create your models here.
class comment(models.Model):
    id = models.AutoField(primary_key=True, db_index=True)
    user = models.ForeignKey("user.user", on_delete=models.CASCADE)
    article = models.ForeignKey("article.articles", on_delete=models.CASCADE)
    content = models.CharField(max_length=2048)
    parent = models.ForeignKey("self", on_delete=models.DO_NOTHING, null=True)
    to_user = models.ForeignKey("user.user", on_delete=models.CASCADE, related_name='to_user', null=True)
    create_time = models.DateTimeField(auto_now_add=True)
    update_time = models.DateTimeField(auto_now=True)

    class Meta:
        db_table = "mblog_comment"
        get_latest_by = 'create_time'
